<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<style>
			div{
			width:200px;
			height: 200px;
			background: red;
			}
			
		</style>
	</head>

	<body>
		<div id="div1"></div>
		<script>
			function getstyle() {
				if(arguments.length == 2) {
					return arguments[0].style[arguments[1]];
				} else if(arguments.length == 3) {
					arguments[0].style[arguments[1]] = arguments[2];
				} else {
					alert("函数调用参数有误！");
				}
			}
			//页面加载时执行
			window.onload = function() {
				//获取div元素
				var div1 = document.getElementById("div1");
				//调用getstyle()
				alert(getstyle(div1, "width"));
				getstyle(div1, "background", "blue   ");
			}
		</script>

	</body>

</html>